﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using lx;

namespace lxhy
{
    public partial class IDForm : Form
    {

        private Action a;
        public IDForm(Action a)
            :this()
        {
            this.a = a;
        }
        private IDForm()
        {
            InitializeComponent();
            int x = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - this.Width;
            int y = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - this.Height;
            Point p = new Point(x, y);
            this.PointToScreen(p);
            this.Location = p;
        }
        private int Seconds; 
        private void label1_Click(object sender, EventArgs e)
        {

        }
        private void ShowTime()
        {
            // 显示剩余时间
            label1.Text = string.Format("{0}", Seconds );
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (--Seconds < 1)
            {
                a();
                this.Close();
            }
            ShowTime();
        }

        private void IDForm_Load(object sender, EventArgs e)
        {
            List<PageData> list = new List<PageData>();
            MyMenu.addColToList(list, "取消本次挡屏", new System.EventHandler(close), null, null);
            MyMenu.addColToList(list, "关闭提示", new System.EventHandler(exit), null, null);
            new MyMenu(label1).addMenu(list);

            this.FormBorderStyle = FormBorderStyle.None;     //设置窗体为无边框样式
            this.Width = 120;
            this.Height = 60;
            // 定时器
            timer1.Interval = 1000;
            timer1.Enabled = false;
            // 定时间隔：120秒
            Seconds = 120;
            ShowTime();
            timer1.Start();
        }
        void close(object sender, EventArgs e)
        {
            this.Close();
        }
        void exit(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void label1_Click_1(object sender, EventArgs e)
        {

        }
    }
}
